package com.ggj2013.hbh;

import com.ggj2013.hbh.utils.Tools;
import nme.display.MovieClip;
import nme.events.Event;
import nme.Lib;
import nme.ui.Mouse;
import nme.display.Bitmap;

/**
 * @author Jonathan Moriarty
 */
class MenuScreen extends MovieClip {
	private var _currTime:Int;
	private var _prevTime:Int;
	private var _deltaTime:Int;
	
	private var _choiceLocked:Int;
	
	private var _background:Bitmap;
	
	public function new() {
		super();
		/*_makePlayButton();
		_makeCreditsButton();
		_makeQuitButton();*/
		
		InputManager.hideMouse();
		
		_background = Tools.loadBitmap("menu_bg");
		_background.x = 0;
		_background.y = 0;
		addChild( _background );
		
		_choiceLocked = -1;
		_prevTime = Lib.getTimer();
	}		
	
	public function update( l_event:Event ):Void {	
		_currTime = Lib.getTimer();
		_deltaTime = _currTime - _prevTime;
		_prevTime = _currTime;
		
		if ( _choiceLocked == -1 )
		{
			if ( InputManager.isKeyPressed( InputManager.P_KEY ) )
			{
				//Tools.trace("P KEY Pressed");
				_choiceLocked = 0;
			}
			
			if ( _choiceLocked == 0 )
			{
				dispatchEvent( new NavigationEvent( NavigationEvent.LEVEL ) );
			}
			else if ( _choiceLocked == 1 )
			{
				//dispatchEvent( new NavigationEvent( NavigationEvent.CREDITS ) );
			}
		}
	}
}
